<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
/* <![CDATA[ */
table, td
{
    border-color: #666;
    border-style: solid;
}
table, th
{
    border-color: #666;
    border-style: solid;
}

table
{
    border-width: 0 0 1px 1px;
    border-spacing: 0;
    border-collapse: collapse;
}
 
td
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}
th
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}
/* ]]> */


</style>
<link rel="stylesheet" href="/js/chosen/chosen2.css" />
</head>
<body style="font-family:Arial, Helvetica, sans-serif" onload="setFocus()" >
<h1>Delivery Slip For <?php echo $this->pon;?></h1>
<table width="600" border="0" cellspacing="1" cellpadding="0">
  <tr>
    <th bgcolor="#00FF00" scope="col">FullFill</th>
    <th bgcolor="#FF8080" scope="col">Refuse / No Sk</th>
    <th bgcolor="#FFFF00" scope="col">Partially</th>
    <th bgcolor="#999999" scope="col">Zero Qty</th>
    <th bgcolor="#6699FF" scope="col">New / Over Sk</th>
  </tr>
</table>
<h2>Date Print :<?php echo $this->dateTime;?><br />
  SCAN OR TYPE CODE,TAB TO SWAP,<br />
  <?php $check2 = true;?>
</h2>
<form id="form1" name="form1" method="post" action="">
<input name="btn_rd" type="submit" value="Remove Duplicated" id="btn_rd" />
  <p>
    <select name="add_part_code" id="add_part_code" class="chzn-select" style="width:500px; height:30px;" tabindex="1" >
      <option value=""></option>
      <?php foreach($this->pList as $rPart ) {?>
      <option value="<?php echo $rPart['id_product']?>">[<?php echo $rPart['code_product']?>]   -  <?php echo $rPart['title_product']?></option>
      <?php } ?>
    </select><br />

    QTY:	
    <input name="qty_add" type="text" id="qty" tabindex="2" value="1" />
  <input type="submit" name="btn_add" id="btn_add" value="ADD" tabindex="3" />
    <input name="arr_allocate_order" type="hidden" value="<?php echo $this->strArrAllo?>" />
  </p>
  <table width="750" border="0" cellspacing="1" cellpadding="0">
    <tr>
    <th >Code</th>
    <th style="width:300px;" >Description</th>
    <th style="width:100px;" >Order</th>
    <th style="width:30px;" >Total</th>
    <th style="width:100px;" >Allocated</th>
    <th style="width:20px;" >&nbsp;</th>
    </tr>
<?php 
	$arrAllo = $this->arrAllo;
	

	$rProduct = new Model_DbTable_Pr_Prproducts();
foreach($this->oList as $key => $v){
	if($v['code_product']!="SERVICE" && $v['code_product']!="CUSTPART" && ($v['qty_order_actual']!=0 || $v['qty_backorder']!=0)){
	
	?> 
	<?php if($v["qty_order_actual"] == 0 && $check2 == true){
				$check = true;?>
			<?php if($check == true){?>
			<tr>
				<th colspan = "6" align = "center"> Back Order List</th>
				<?php $check2 = false;?>
			</tr>
			<?php }?>
	<?php }?>
  <tr 
 <?php
	//set background 
	$alloQty = 0;
	if(!isset($arrAllo[$v['id_product']]) && $v["qty_allocate"] == 0){
		//refused
		if($v["qty_order_actual"] > 0){
			
			echo 'style="background-color:#FF8080;"';
		}
		else{
			echo 'style="background-color:#999999;"';
		}
		//zero qty
		} 
	else{
		//full fill
		if(!isset($arrAllo[$v['id_product']]) && $v["qty_allocate"] > 0){
			$alloQty =  $v["qty_allocate"];
			}
		else{
			$alloQty = $arrAllo[$v['id_product']];
			}	
		
		if($alloQty > $v["qty_order"] ){
			echo 'style="background-color:#6699FF;"';
			}
		if($alloQty == $v["qty_order"] ){
			echo 'style="background-color:#00FF00;"';
			}
		if($alloQty < $v["qty_order"] ){
			echo 'style="background-color:#FFFF00;"';
			}
		if($alloQty == 0){
			echo 'style="background-color:#FF8080;"';
			}			
		//partially	
	unset($arrAllo[$v['id_product']]);
	}
	//$str = ($v["qty_order_actual"]==0 && $alloQty==0 )?"text-decoration:line-through":"";
 ?> 
 >
    <td><?php echo $v['code_product']?></td>
    <td><span style="font-size:12px;"><?php echo $rProduct->getProductDes($v['code_product'])?></span></td>
    <td><?php echo $v['qty_order_actual']?> + [<?php echo $v['qty_backorder']?>]</td>
    <td><?php echo ($v['qty_order_actual'] + $v['qty_backorder'])?></td>
    <td><input type="text" name="qty_alloc[<?php echo $v['id_product']?>]" id="qty_alloc<?php echo $v['id_product']?>" value="<?php echo $alloQty?>" /></td>
    <td><input type="checkbox" name="id_modify[<?php echo $v['id_product']?>]" id="id_modify<?php echo $v['id_product']?>" title="Modified" value="<?php echo $v['id_product']?>" /></td>
  </tr>
<?php }

}?>  
<?php 
if(!empty($arrAllo)){
foreach($arrAllo as $kn => $vn){
	$pRow = $rProduct->getProduct($kn);
	//var_dump($pRow);
?>
  <tr style="background:#69F" >
    <td><?php echo $pRow['code_product']?></td>
    <td><span style="font-size:12px;"><?php echo $pRow['title_product'] ?></span></td>
    <td>0 <span style="font-size:12px;">[no-order]</span></td>
    <td>0</td>
    <td><input type="text" name="qty_alloc[<?php echo $kn?>]" id="qty_alloc<?php echo $kn?>" value="<?php echo $vn?>" /></td>
    <td><input type="checkbox" name="id_modify[<?php echo $kn?>]" id="id_modify<?php echo $kn?>" title="Modified" value="<?php echo $kn?>" /></td>
  </tr>
<?php } }?>
<tr>
<td style="padding:20px; text-align:right;" colspan="5">
  <input type="submit" name="btn_modify" id="btn_modify" value="Save Modify QTY" />&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="submit" name="btn_confirm" id="btn_confirm" value="Confirm &amp; Notify Shop " />
</td>
</tr>
</table>
  <br />
  <br />

</form>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="/js/chosen/chosen.jquery.js" type="text/javascript"></script>
<script type="text/javascript"> 
    var config = {
      '.chzn-select': {allow_single_deselect:true},
    }
    for (var selector in config) {
      $(selector).chosen(config[selector]);
    };
	
$(document).ready(function() {

$('input:text[id^=qty_alloc]').change(function(){
	var id = $(this).attr("id");
	var line = 0;
	var length = id.length;
	
	line = id.substring(9,length);
	//alert(line);
	$('#id_modify' + line).attr("checked","checked");
	});
});

function setFocus()
{
document.getElementById("add_part_code").focus();
}	
  </script>
 <div style=" font-size:10px; color:#666;float:right;" >Developer:Leo,Date:2015-06-03,ver:1.01</div>
</body>
</html>
